#ifndef _GFUNS
#define _GFUNS

#include "allegro5/allegro_color.h"
#include "allegro5/allegro_primitives.h"
#include "dataTypes.h"
#include <string>
using namespace std;

// Random seed managment
void PushRand(int aRand);
int PopRand();

// converts int to string
string iToString(int i);

// draws a rectangle with ountline
void draw_rectangle(float aX1, float aY1, float aX2, float aY2, ALLEGRO_COLOR aFill, ALLEGRO_COLOR aBord, float aThik);

// draws a rounded rectangle with ountline
void draw_rounded_rectangle(float aX1, float aY1, float aX2, float aY2, float aRX, float aRY, ALLEGRO_COLOR aFill, ALLEGRO_COLOR aBord, float aThik);

// draws a triangle with ountline
void draw_triangle(float aX1, float aY1, float aX2, float aY2, float aX3, float aY3, ALLEGRO_COLOR aFill, ALLEGRO_COLOR aBord, float aThik);

// draws a ellipse with ountline
void draw_ellipse(float aCX, float aCY, float aRX, float aRY, ALLEGRO_COLOR aFill, ALLEGRO_COLOR aBord, float aThik);

// draws a quad with outline
void draw_quad(Node verts[4], ALLEGRO_COLOR aFill, ALLEGRO_COLOR aBord, float aThik);

// returns from 0 to 1, closer to 0
double randNorm();

// compares two colors
bool eq(ALLEGRO_COLOR aCol1, ALLEGRO_COLOR aCol2);

// return a double from a given interval
double randInterval(double aBegin, double aEnd);

// return an integer from a given interval
int randInt(int aBegin, int aEnd);

// draws regular line for node aN1 to aN2
void drawLine(Node aN1, Node aN2, ALLEGRO_COLOR aCl, int aThik);

// draws sRectangle
void drawRect(sRectangle aRect, ALLEGRO_COLOR aFillCol, ALLEGRO_COLOR aBordCol, int aThick = 1);
void drawRect(sRectangle aRect, ALLEGRO_COLOR aBordCol, int aThick);
void drawRect(sRectangle aRect, ALLEGRO_COLOR aFillCol);

// draw a gradient square
void drawGradient(float x1, float y1, float x2, float y2, ALLEGRO_COLOR c1, ALLEGRO_COLOR c2);

// draw line from point aX,aY at aLen length and at aDir direction
// if aOverride is true, aX and aY gets the value of a second end of the line
void drawDirectLine(float& aX, float& aY, float aLen, float aDir, ALLEGRO_COLOR aColor, float aThik, bool aOverwrite = false);

// draw bitmap with specified alpha
void drawAlphaBitmap(ALLEGRO_BITMAP* aBitmap, unsigned char aAlpha, float aX, float aY, float aFlags );

// draw scaled bitmap with specified alpha
void drawScaledAlphaBitmap(ALLEGRO_BITMAP* aBitmap, unsigned char aAlpha, float aSX, float aSY, float aSW, float aSH,
	float aDX, float aDY, float aDW, float aDH, float aFlags );

// changes pixel color on a target bitmap with random probability
void noise(ALLEGRO_COLOR aCol1, ALLEGRO_COLOR aCol2, int aProb);

// blurs input bitmap into output
void blur(ALLEGRO_BITMAP* aIn, ALLEGRO_BITMAP* aOut);

// not working!
/*Node getSplinePoint(float x1, float y1, float x2, float y2, float aLen, bool aPos);*/

#endif